﻿<?php
	//dieu kien loc theo STT,do dai,thoi gian ....
	$q=$_GET["q"];
	//dieu kien loc theo camera
	$camera_id = $_GET["camera_id"];
	//ket noi toi database
	$conn=mysql_connect("localhost","root","abc123") or die(" Không thể kết nối");
	mysql_select_db("detaiptntd",$conn);
	//cau lenh truy van		
	$sql = "select * from video where idMonitor = '".$camera_id."' order by ".$q."";	
	
	if($camera_id=="" && $q=="")
		$sql = "select * from video";
	else
	{
		if($camera_id=="")
			$sql = "select * from video order by ".$q."";	
		if($q=="")
			$sql = "select * from video where idMonitor = '".$camera_id."'";
	}
	//thuc thi truy van lay video theo dk
	$query=mysql_query($sql);
	//so phan tu tra ve cua lenh $query
	$numrow = mysql_num_rows($query);
	//kiem tra ket qua 
	if( $numrow == 0)
	{
		echo "<p style=\"color:#FF0000\">Chưa có dữ liệu về lịch sử quay của camera này trong cơ sở dữ liệu </p>";
	}
	else
	{			
		echo "<table id=\"table-6\">";
		echo "<thead>
			<th>Số TT</th>
			<th>Loại Camera</th>
			<th>Thời gian bắt đầu</th>
			<th>Độ dài</th>
			<th>Chạy video</th>
			</thead>
			<tbody>";

		while($info = mysql_fetch_array( $query )) 
		{ 							
			echo "	
			<tr>
				<td>".$info[id]."</td>
				<td>".$info[name]."</td>
				<td>".$info[startTime]."</td>
				<td>".$info[length]."</td>				
				<td>
				<a href=\"JavaScript:newPopup('../playvideo.php?linkvideo=".$info[videopath]."&videoFormat=".$info[videoFormat]."&eventWidth=".$info[eventWidth]."&eventHeight=".$info[eventHeight]."');\">Chạy video</a>
				</td>
			</tr>";				
		}
		echo "</tbody>
			</table>";	
		mysql_close($conn);
	}			
?>